import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token: null,
    // mobile: 移动端, pad: 小屏(平板等), pc: 大屏
    device: 'pc',
    // 全屏加载遮罩，用于接口请求时的loading
    loading: false
  },
  getters: {
    isMobile: state => {
      return state.device === 'mobile'
    },
    isPad: state => {
      return state.device === 'pad'
    },
    isPC: state => {
      return state.device === 'pc'
    },
    // element弹窗宽度
    dialogWidth: state => {
      if (state.device === 'mobile') {
        return '95vw'
      }
      if (state.device === 'pad') {
        return '600px'
      }
      return '800px'
    }
  },
  mutations: {
    setToken (state, token) {
      state.token = token
    },
    setDevice (state, device) {
      state.device = device
    }
  },
  actions: {},
  modules: {}
})
